import { RuleConfigSeverity } from "@commitlint/types";

module.exports = {
  extends: ["@commitlint/config-conventional"],
  // Custom rule: body must be contained the story id
  rules: {
    "body-contains-story-id": () => [RuleConfigSeverity.Warning, "always"],
  },
  plugins: [
    {
      rules: {
        "body-contains-story-id": ({ body }) => {
          const content = body && body.trim();
          const regex = /--story=\d{7,}/;
          return [
            content && regex.test(content),
            'Body must contain a story ID in the format "--story=数字',
          ];
        },
      },
    },
  ],
};
